package com.shou.controller;//package com.shou.controller;

import com.shou.pojo.Activity;
import com.shou.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

// ActivityController.java
@RestController
@RequestMapping("/activities")
public class ActivityController {

    @Autowired
    private ActivityService activityService;

    @GetMapping("/{id}")
    public ResponseEntity<Activity> getActivityById(@PathVariable int id) {
        Activity activity = activityService.findById(id);
        return ResponseEntity.ok(activity);
    }

    @GetMapping("/all")
    public ResponseEntity<List<Activity>> getAllActivities() {
        List<Activity> activities = activityService.getAllActivities();
        return ResponseEntity.ok(activities);
    }

    // Other CRUD operations for activities

    @PostMapping("/{activityId}/enroll/{userId}")
    public ResponseEntity<String> enrollUser(@PathVariable int activityId, @PathVariable int userId) {
        activityService.enrollUser(userId, activityId);
        return ResponseEntity.ok("Enrollment successful");
    }
}
